﻿using System;
using System.Collections.Generic;
using System.Text;

namespace OneStop.Calculations
{
    public class GasVolumeComparer : IComparer<Gas>
    {
        public enum SortOrder
        {
            Ascending,
            Descending
        }

        #region Properties

        public SortOrder Direction
        {
            get;
            set;
        }

        #endregion

        #region Constructors

        public GasVolumeComparer()
        {
            this.Direction = SortOrder.Ascending;
        }

        public GasVolumeComparer(SortOrder direction)
        {
            this.Direction = direction;
        }

        #endregion

        #region Methods

        int IComparer<Gas>.Compare(Gas x, Gas y)
        {
            if (this.Direction == SortOrder.Ascending)
            {
                return x.Volume.CompareTo(y.Volume);
            }
            else
            {
                return y.Volume.CompareTo(x.Volume);
            }
        }

        #endregion
    }
}
